package com.heng.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.heng.dao.entity.Coupon;
import com.heng.dao.entity.UserCoupon;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

// 优惠券Mapper
public interface CouponMapper extends BaseMapper<Coupon> {
    // 条件查询优惠券（状态、时间、库存）
    @Select("SELECT * FROM t_coupon WHERE status = #{status} " +
            "AND start_time <= NOW() AND end_time >= NOW() " +
            "AND surplus_stock > 0 " +
            "AND id = #{couponId}")
    Coupon selectValidCouponById(@Param("couponId") Long couponId, @Param("status") Integer status);
}

